package proxy.jdk;

import proxy.SmsService;
import proxy.SmsServiceImpl;

import java.lang.reflect.Proxy;

/**
 * @Author: DRevelation
 * @Date: 2021/3/31 17:34
 */
public class JdkProxyFactory {
    public static Object getProxy(Object target) {
        return Proxy.newProxyInstance(target.getClass().getClassLoader(),
                target.getClass().getInterfaces(), new DebugInvocationHandler(target));
    }

    public static void main(String[] args) {
        SmsService smsService = (SmsService) JdkProxyFactory.getProxy(new SmsServiceImpl());
        smsService.send("java");
    }
}
